package com.benny_driving_dri.thread;

import com.benny_driving_dri.act.TaximeterAct2;
import com.benny_driving_dri.dao.impl.HttpDaoImpl;
import com.benny_driving_dri.entity.Taximeter2Data;

public class SettlementForTaximeter2Thread extends Thread {
	private String jsessionId;
	private Taximeter2Data t2d;

	public SettlementForTaximeter2Thread(String jsessionId, Taximeter2Data t2d) {
		this.jsessionId = jsessionId;
		this.t2d = t2d;
	}

	@Override
	public void run() {
		// String price = "";
		HttpDaoImpl hdi = new HttpDaoImpl();
		if (null != TaximeterAct2.handler) {
			String resValue = hdi.sendTaximeterData(jsessionId, t2d);
			String[] resValues = resValue.split("/");
			if (!resValues[0].equals("false")) {
				TaximeterAct2.handler.sendMessage(TaximeterAct2.handler
						.obtainMessage(0, TaximeterAct2.HANDLER_KEY_SETTLEMENT,
								TaximeterAct2.HANDLER_STATE_SUCCESS,
								resValues[1]));
			} else {
				TaximeterAct2.handler
						.sendMessage(TaximeterAct2.handler.obtainMessage(0,
								TaximeterAct2.HANDLER_KEY_SETTLEMENT,
								TaximeterAct2.HANDLER_STATE_FAIL, resValues[1]));
			}
		}
	}

}
